package smedi.ismedi.mobile.bff.controller.safetyeducation;

import com.smedi.ismedi.safety.education.api.dto.request.SpecialTrainingQueryRequest;
import com.smedi.ismedi.safety.education.api.dto.request.SpecialTrainingUpdateRequest;
import com.smedi.ismedi.safety.education.api.dto.response.PaginationResponse;
import com.smedi.ismedi.safety.education.api.dto.response.SpecialTrainingResponse;
import com.smedi.ismedi.safety.education.api.feign.RemoteSpecialTrainingFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.io.IOException;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mobilebff/v1/specialTraining")
@AllArgsConstructor
@Api(tags = "专项培训API")
public class SpecialTrainingController extends BaseController {
    private final RemoteSpecialTrainingFeignApi remoteSpecialTrainingFeignApi;

    /**
     * 创建专项培训
     *
     * @param specialTrainingUpdateRequest
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "创建专项培训")
    @PostMapping(value = "/saveSpecialTraining")
    public ResponseData<SpecialTrainingResponse> postSaveSpecialTraining(@Validated @RequestBody SpecialTrainingUpdateRequest specialTrainingUpdateRequest) {
        return remoteSpecialTrainingFeignApi.postSaveSpecialTraining(specialTrainingUpdateRequest);
    }

    /**
     * 删除专项培训
     *
     * @param ids
     * @return
     */
    @ApiOperation(httpMethod = "DELETE", value = "删除专项培训")
    @DeleteMapping(value = "/deleteSpecialTraining")
    public ResponseData deleteSpecialTraining(@Validated @RequestBody List<Long> ids) {
        return remoteSpecialTrainingFeignApi.deleteSpecialTraining(ids);
    }

    /**
     * 查询专项培训
     *
     * @param specialTrainingQueryRequest
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "查询专项培训")
    @GetMapping(value = "/querySpecialTraining")
    public ResponseData<PaginationResponse> getQueryAllSpecialTraining(@Validated @SpringQueryMap SpecialTrainingQueryRequest specialTrainingQueryRequest) {
        return remoteSpecialTrainingFeignApi.getQueryAllSpecialTraining(specialTrainingQueryRequest);
    }

    @ApiOperation(httpMethod = "GET", value = "查询单个专项培训信息")
    @GetMapping(value = "/querySpecialTrainingInfo")
    public ResponseData<SpecialTrainingResponse> getSpecialTrainingInfo(@RequestParam("id") Long id) {
        return remoteSpecialTrainingFeignApi.getSpecialTrainingInfo(id);
    }

    @ApiOperation(httpMethod = "GET", value = "导出单个专项培训信息")
    @GetMapping(value = "/exportSpecialTrainingInfo")
    public void exportSpecialTraining(@RequestParam("id") Long id) throws IOException {
        remoteSpecialTrainingFeignApi.exportSpecialTraining(id);
    }

    @ApiOperation(httpMethod = "GET", value = "导出多个专项培训信息")
    @GetMapping(value = "/exportSpecialTrainingBatch")
    public void exportSpecialTrainingBatch(@Validated @RequestBody List<Long> ids) throws IOException {
        remoteSpecialTrainingFeignApi.exportSpecialTrainingBatch(ids);
    }
}
